import request from './request';

export function fetchProducts(params) {
  return request.get('/products', { params });
}

export function addProduct(data) {
  return request.post('/product', data);
}

export function updateProduct(id, data) {
  return request.put(`/product/${id}`, data);
}

export function deleteProduct(id) {
  return request.delete(`/product/${id}`);
}

export function fetchFollowedProducts() {
  return request.get('/products/followed');
}

export function unfollowProduct(id) {
  return request.patch(`/product/${id}/unfollow`);
}

export function fetchProductDetail(id) {
  return request.get(`/product/${id}`);
} 

export function fetchProductVersion() {
  return request.get('/product-version');
}

export function switchProductVersion(version) {
  return request.post('/switch-version', { version });
}

// 获取线上版本
export function fetchOnlineVersion() {
  return request.get('/online-version');
}

// 设置线上版本
export function setOnlineVersion(onlineVersion) {
  return request.post('/online-version', { onlineVersion });
}
